using System;
using Microsoft.WindowsCE.Forms;
using System.Drawing;

namespace ChrisTec.WindowsMobile.TodayScreen
{
  public static class TodayScreenColors
  {
    private const int TODAYM_GETCOLOR = 0x0400 + 100;
    private const int TODAYCOLOR_TEXT = 0x10000004;
    private const int TODAYCOLOR_HIGHLIGHT = 0x10000022;
    private const int TODAYCOLOR_HIGHLIGHTEDTEXT = 0x10000023;

    private static Color GetColor(int id)
    {
      Message msg = new Message();
      msg.HWnd = TodayScreen.NativeHandle;
      msg.Msg = TODAYM_GETCOLOR;
      msg.LParam = IntPtr.Zero;
      msg.WParam = (IntPtr)id;
      MessageWindow.SendMessage(ref msg);

      int red   = ((int)msg.Result & 0x000000FF) >> 0;
      int green = ((int)msg.Result & 0x0000FF00) >> 8;
      int blue  = ((int)msg.Result & 0x00FF0000) >> 16;

      return Color.FromArgb(red, green, blue);
    }
    
    public static Color Text
    {
      get { return GetColor(TODAYCOLOR_TEXT); }
    }

    public static Color Highlight
    {
      get { return GetColor(TODAYCOLOR_HIGHLIGHT); }
    }

    public static Color HighlightedText
    {
      get { return GetColor(TODAYCOLOR_HIGHLIGHTEDTEXT); }
    }
  }
}
